import {
  exportUrl,
  downloadTemplateUrl,
  getCreateTypeList,
} from '@/api/materialRequisition/mesRequisitionBill'

import { exportExcel } from '@/utils/judge'

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t('common.export'),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl,
    //auth: "auth:operlog:export", //权限字段
  },
  {
    name: $i18n.t("mesRequisitionBill.requireMaterial"),
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "requireMaterial", //点击时返回的标识
  },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   icon: "el-icon-delete",
  //   handleName: "deleteBatch", //点击时返回的标识
  //   isMultiple: true, // isSingle 表示必须选择一项//isMultiple: true, // 表示必须多选
  // },
  // {
  //   name: $i18n.t("common.import"),
  //   type: "primary",
  //   icon: "el-icon-circle-plus-outline",
  //   handleName: "import", //点击时返回的标识
  // },
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.edit"),
    type: "primary",
    class: "row-btn-primary",
    handleName: "edit", //点击时返回的标识
  },
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail", //点击时返回的标识
  },
  {
    name: $i18n.t("common.delete"),
    type: "danger",
    class: "row-btn-danger",
    handleName: "delete", //点击时返回的标识
  },
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    planCode: {
      type: 'input',
      label: $i18n.t('mesRequisitionBill.planCode'),  // 生产订单编码
    },
    prodCode: {
      type: 'input',
      label: $i18n.t('mesRequisitionBill.prodCode'),  // 产品编码
    },
    prodName: {
      type: 'input',
      label: $i18n.t('mesRequisitionBill.prodName'),  // 产品名称
    },
    createType: {
      type: 'select',
      label: $i18n.t('mesRequisitionBill.createType'),  // 创建类型（0-排程创建，1、人工创建）
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getCreateTypeList()
        return list.data.result
      },
    },
    materialCode: {
      type: 'input',
      label: $i18n.t('mesRequisitionBill.materialCode'),  // 物料编码
    },
    materialName: {
      type: 'input',
      label: $i18n.t('mesRequisitionBill.materialName'),  // 物料名称
    },

  },
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    planCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.planCode"),  // 生产订单编码
      layout: 12,
      required: false,
    },
    planQuantity: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.planQuantity"),  // 订单计划数量
      layout: 12,
      required: false,
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.seriesCode"),  // 系列编码
      layout: 12,
      required: false,
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.seriesName"),  // 系列名称
      layout: 12,
      required: false,
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.prodCode"),  // 产品编码
      layout: 12,
      required: true,
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.prodName"),  // 产品名称
      layout: 12,
      required: false,
    },
    materialCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.materialCode"),  // 物料编码
      layout: 12,
      required: false,
    },
    materialName: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.materialName"),  // 物料名称
      layout: 12,
      required: false,
    },
    unitCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.unitCode"),  // 计量单位编码
      layout: 12,
      required: true,
    },
    unit: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.unit"),  // 计量单位名称
      layout: 12,
      required: true,
    },
    bomVersion: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.bomVersion"),  // BOM版本号
      layout: 12,
      required: false,
    },
    singleQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.singleQty"),  // 最小单位需求量
      layout: 12,
      required: true,
    },
    needQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.needQty"),  // 需求数量(标准用量)
      layout: 12,
      required: true,
    },
    lossQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.lossQty"),  // 损耗数量：标准用料 *(物料损耗率/100)
      layout: 12,
      required: true,
    },
    receiveQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.receiveQty"),  // 已领数量
      layout: 12,
      required: true,
    },
    unReceiveQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.unReceiveQty"),  // 未领数量（需求数量-已领数量+已退数量）
      layout: 12,
      required: true,
    },
    backQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.backQty"),  // 已退数量
      layout: 12,
      required: true,
    },
    pickQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.pickQty"),  // 领料中数量
      layout: 12,
      required: true,
    },
    returnQty: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.returnQty"),  // 退料中数量
      layout: 12,
      required: true,
    },
    advancingStockDays: {
      type: "number",
      label: $i18n.t("mesRequisitionBill.advancingStockDays"),  // 提前备货期限（T-）天
      layout: 12,
      required: false,
    },
    sourceType: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.sourceType"),  // 数据来源 1-mes 2-wms 3-其它
      layout: 12,
      required: true,
    },
    createType: {
      type: "select",
      label: $i18n.t("mesRequisitionBill.createType"),  // 创建类型（0-排程创建，1、人工创建）
      layout: 12,
      required: true,
      prop: {
        value: "value",
        text: "description",
      },
      options: async (data) => {
        const list = await getCreateTypeList()
        return list.data.result
      },
    },
    factoryCode: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.factoryCode"),  // 工厂编码
      layout: 12,
      required: true,
    },
    remark: {
      type: "input",
      label: $i18n.t("mesRequisitionBill.remark"),  // 备注
      layout: 12,
      required: false,
    },
  },
}
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",
      layout: 24,
      required: false,
      title: $i18n.t("common.downloadTemplate"), // 下载模板
      style: {
        color: '#1867c0',
        fontSize: '14px'
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("common.chooseFile"),
      layout: 24,
      // required: true,

    },
  }
}

